<template>
	<div class="smp-result smp_panel_1">
		<div class="smp_panel_header">
			<div class="smp_panel_pre"></div>
			<div class="smp_panel_title">环境信息</div>
		</div>
		<div class="smp_panel_body">
			<el-table :data="list" size="mini" stripe border style="width: 100%">
				<el-table-column prop="hostName" label="主机名" align="center">
				</el-table-column>

				<el-table-column prop="systemCurrentAddr" label="IP地址" align="center">
				</el-table-column>

				<el-table-column prop="esbAddr" label="ESB地址" align="center">
					<template slot-scope="scope">
						<!-- {{scope.row.esbAddr|dictName("SMP0016")}} -->
						{{scope.row.esbAddr|getESBEnvironment(that)}}
					</template>


				</el-table-column>

				<el-table-column prop="envirType" label="环境类型" align="center">
					<template slot-scope="scope">
						{{scope.row.envirType|dictName("SMP0026")}}
					</template>

				</el-table-column>

				<el-table-column prop="hosts" label="HOSTS" align="center">
				</el-table-column>

				<el-table-column prop="status" label="状态" align="center">
					<template slot-scope="scope">
						{{scope.row.status|dictName("SMP0005")}}
					</template>
				</el-table-column>
			</el-table>

			<div class="smp-pagination">
				<el-pagination background size="medium" layout="total,sizes,prev, pager, next,jumper"
					:page-size="query.pageSize" :page-sizes="[5,10,15,20]" :total="total" :current-page="query.pageNum"
					@current-change="currentChange" @size-change="sizeChange">
				</el-pagination>
			</div>
		</div>
	</div>
</template>

<script>
	"use strict";
	import {
		getEnvironmentInfoByPage,
		getEsbEnvironmentByEsbFlg
	} from '@/api/environment.js';
	export default {

		data() {

			return {
				esbEnvironmentList: [],
				that:this,
				query: {
					body: {
						systemNo: '',

					},
					pageNum: 1,
					pageSize: 5
				},
				total: 0,
				list: []
			};
		},


		props: {
			row: {
				type: Object,
			}
		},

		created() {
			this.query.body.systemNo = this.row.systemNo;
			/* this.query.pageNum = 1; */
			this.getEsbEnvironmentList();
			this.getInfo();

		},
		
		filters: {
			getESBEnvironment: function(ip,that) {
			
				let esbEnvironment =  that.esbEnvironmentList.filter(item=>item.ip==ip)[0];
				return esbEnvironment.ip +"(" + that.dictName(esbEnvironment.esbFlg,'SMP0031') +")";
			}
		},
				
		methods: {
			
			getEsbEnvironmentList() {
				getEsbEnvironmentByEsbFlg({}).then(response => {
					this.esbEnvironmentList = response.data.extend;
				})
			},
						

			getInfo() {
				getEnvironmentInfoByPage(this.query).then(response => {
					this.list = response.data.extend.list;
					this.total = response.data.extend.total;
				}).catch(error => {
					console.info("失败");
					console.info(error.message);
				});
			}
		}
	}
</script>

<style>
</style>
